﻿#region Using namespaces

using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.IO;

#endregion

namespace BOL.Apps.GeneNetworkBrowser.ViewModels
{
    public class DocumentViewModel : ViewModelBase
    {
        #region Protected variables

        protected const string _untitledFile = "Untitled";
        protected string _filePath;
        //protected RelayCommand _closeCommand;

        #endregion

        #region Public properties
        
        public string FilePath
        {
            get { return _filePath; }
            set
            {
                if (value != _filePath)
                {
                    _filePath = value;

                    OnPropertyChanged(new string[3] { "FilePath", "FileName", "Title" });
                }
            }
        }

        public string FileName
        {
            get
            {
                if (string.IsNullOrEmpty(FilePath))
                    return _untitledFile;

                return Path.GetFileName(FilePath);
            }
        }

        public override string Title { get { return (IsChanged) ? String.Format("{0}*", FileName) : FileName; } }

        //public ICommand CloseCommand
        //{
        //    get
        //    {
        //        if (_closeCommand == null)
        //            _closeCommand = new RelayCommand(param => OnClosed());

        //        return _closeCommand;
        //    }
        //}

        //public event EventHandler Closed;

        //void OnClosed()
        //{
        //    if (Closed != null)
        //        Closed(this, EventArgs.Empty);
        //}

        #endregion

        #region Constructor

        public DocumentViewModel(string filePath)
        {
            _filePath = filePath;
        }

        #endregion
    }
}
